﻿using System;
using System.Windows.Forms;
using Server.Model;

namespace Server.Menus
{
    public partial class ServerMainMenu : Form
    {
        private readonly ServerData _servData;

        private readonly RegisteredClients _registeredClients;

        private readonly KnownServers _knownServers;

        private readonly OtherInformation _otherInfo;

        private readonly SecretForm _secretForm;

        private readonly OperationsForm _opForm;

        public ServerMainMenu( ServerData servData )
        {
            _servData = servData;
            _registeredClients = new RegisteredClients( servData );
            _knownServers = new KnownServers( servData );
            _otherInfo = new OtherInformation( servData );
            _secretForm = new SecretForm( );
            _opForm = new OperationsForm( servData );
            InitializeComponent( );
        }

        private void button1_Click( object sender, EventArgs e )
        {
            _registeredClients.Activate( );
            _registeredClients.Show( );
        }

        private void button2_Click( object sender, EventArgs e )
        {
            _knownServers.Activate( );
            _knownServers.Show( );
        }

        private void button3_Click( object sender, EventArgs e )
        {
            _otherInfo.Activate( );
            _otherInfo.Show( );
        }

        private void padiCalServer_MouseDoubleClick( object sender, MouseEventArgs e )
        {
            if( !Visible )
            {
                Show( );
                WindowState = FormWindowState.Normal;
            }
        }

        private void ServerMainMenu_Resize( object sender, EventArgs e )
        {
            ServerMainMenu serv = sender as ServerMainMenu;

            if( serv.WindowState == FormWindowState.Minimized )
            {
                Hide( );
                WindowState = FormWindowState.Normal;
            }
        }

        private void ServerMainMenu_FormClosed( object sender, FormClosedEventArgs e )
        {
            padiCalServer.Visible = false;
        }

        private void ServerMainMenu_DoubleClick( object sender, EventArgs e )
        {
            _secretForm.Show( );
        }

        private void ServerMainMenu_Load( object sender, EventArgs e )
        {
            Text = String.Format( "Server {0} Information", _servData.ServerId );
            padiCalServer.Text = String.Format( "PADICal {0}", _servData.ServerId );
        }

        private void button4_Click( object sender, EventArgs e )
        {
            _opForm.Activate( );
            _opForm.Show( );
        }
    }
}